package 数据结构练习;

public class 选择排序 {
    public static void main(String[] args) {
        int a[] = new int[]{5,9,6,7,3,1,2,4,8};
        sort(a);
        for(int x:a){
            System.out.print(x+" ");
        }
    }

    public static void sort(int[] a){
        int min = 99999999;
        int point=0,temp=0;
        for(int i=0;i<a.length-1;i++){
            for(int j=i;j<a.length;j++){
                if(a[j] < min){
                    min = a[j];
                    point = j;
                }
            }
            //这里初始化最小值
            min = 99999999;
            temp = a[i];
            a[i] = a[point];
            a[point] = temp;
        }
    }
}
